home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / tests / button.c next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  3.4 KB  |  144 lines

  1. /*
  2.  *  my_stubs.c - derived from Button_stubs.c 
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <sys/param.h>
  7. #include <sys/types.h>
  8. #include <xview/xview.h>
  9. #include <xview/panel.h>
  10. #include <xview/textsw.h>
  11. #include <xview/xv_xrect.h>
  12. #include <gdd.h>
  13. #include "Button_ui.h"
  14.  
  15. #include "Browse.h"
  16.  
  17. #ifdef MAIN
  18.  
  19. /* $Header: /Source/Media/warren/Browse/RCS/Button.c,v 0.15 91/05/30 11:50:26 warren Exp Locker: warren $ */
  20. /* $Log:    Button.c,v $
  21.  * Revision 0.15  91/05/30  11:50:26  warren
  22.  * Making all rev numbers the same -- about to ci a new version to collab
  23.  * 
  24.  * Revision 0.10  1991/05/09  01:40:43  warren
  25.  * *** empty log message ***
  26.  * */
  27. static char rcsid[] = "$Header: /Source/Media/warren/Browse/RCS/Button.c,v 0.15 91/05/30 11:50:26 warren Exp Locker: warren $";
  28.  
  29.  
  30. /* Instance XV_KEY_DATA key.  An instance is a set of related
  31.  * user interface objects.  A pointer to an object's instance
  32.  * is stored under this key in every object.  This must be a
  33.  * global variable.
  34.  */
  35. Attr_attribute    INSTANCE;
  36. char *keepIt;
  37. int OpenHandler(), SaveHandler();
  38.  
  39. void
  40. main(argc, argv)
  41.     int        argc;
  42.     char        **argv;
  43. {
  44.     Button_window1_objects    *Button_window1;
  45.     
  46.     /*
  47.      * Initialize XView.
  48.      */
  49.     xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
  50.     INSTANCE = xv_unique_key();
  51.     
  52.         /*
  53.      * Initialize user interface components.
  54.      */
  55.     Button_window1 = Button_window1_objects_initialize(NULL, NULL);
  56.     CreateBrowse(OpenHandler, SaveHandler, 
  57.             Button_window1->window1);    /* Create the Browse with window1 as owner */
  58.  
  59.     
  60.     /*
  61.      * Turn control over to XView.
  62.      */
  63.     xv_main_loop(Button_window1->window1);
  64.     exit(0);
  65. }
  66.  
  67. #endif
  68.  
  69.  
  70. int
  71.   OpenHandler(char *proposedPath, int id)
  72. {
  73.   char *errorMessage;
  74.   
  75.   if (strcmp("mmmmmm", proposedPath) != 0)
  76.     {
  77.     printf("Button: OpenHandler thinks that %s \nlooks like a good path.\n", proposedPath);      
  78.     keepIt = (char *)strdup(proposedPath);                    /* Keep a copy for use elsewhere */
  79.     return 0;
  80.   }
  81.   else
  82.     {
  83.       errorMessage = (char*)malloc(50*sizeof(char));
  84.       sprintf(errorMessage, "OpenHandler does not like the name 'mmmmmm'\n");
  85.       free(proposedPath);
  86.       proposedPath = errorMessage;
  87.       return(1);
  88.   }
  89. }
  90.  
  91. int
  92.   SaveHandler(char *proposedPath, int id)
  93. {
  94.   char *errorMessage;
  95.   
  96.   if (strcmp("mmmmmm", proposedPath) != 0)
  97.     {
  98.     printf("Button: SaveHandler thinks that %s \nlooks like a good path.\n", proposedPath);      
  99.     keepIt = (char *)strdup(proposedPath);                    /* Keep a copy for use elsewhere */
  100.     return 0;
  101.   }
  102.   else
  103.     {
  104.       errorMessage = (char*)malloc(50*sizeof(char));
  105.       sprintf(errorMessage, "SaveHandler does not like the name 'mmmmmm'\n");
  106.       free(proposedPath);
  107.       proposedPath = errorMessage;
  108.       return(1);
  109.   }
  110. }
  111.  
  112. /*
  113.  * Notify callback function for `open'.
  114.  */
  115. void
  116. openNotify(item, event)
  117.     Panel_item    item;
  118.     Event        *event;
  119. {
  120.   Button_window1_objects    *ip = (Button_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  121.   char *path = "/Source";                        /* Where to start browsing */
  122.  
  123.   fputs("Button: openNotify\n", stderr);
  124.   Browse(NULL, BrowseOpen, NULL, NULL, NULL);     /* Now use it */
  125. }
  126.  
  127. /*
  128.  * Notify callback function for `save'.
  129.  */
  130. void
  131. saveNotify(item, event)
  132.     Panel_item    item;
  133.     Event        *event;
  134. {
  135.   Button_window1_objects    *ip = (Button_window1_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  136.   char *path = "/Source";                        /* Where to start browsing */
  137.  
  138.   fputs("Button: openNotify\n", stderr);
  139.   Browse(NULL, BrowseSave, NULL, "#Shell Edit File#", "ShellEdit");      /* Now use it */
  140. }
  141.  
  142.  
  143.  
  144.